package br.unesp.demac.ccn2007.aulas5.ex01_swing;

import javax.swing.*;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.SystemColor;
import java.awt.event.*;


public class Exemplo3Gui extends JFrame{

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	@SuppressWarnings("unused")
	private JButton btAbrir, btSalvar, btFechar;
	@SuppressWarnings("unused")
	private JTextArea taEditor;

	public Exemplo3Gui(){
		super("Exemplo 3");
		setSize(300,200);
		setBackground(SystemColor.control);
		JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));

		for(int i = 0; i<3; i++){
			p1.add(new JLabel (new ImageIcon(
					getClass().getResource("imagens/Emoticon_happy.png"))));
			p1.add(new JLabel (new ImageIcon(
					getClass().getResource("imagens/emoticon-tongue.png"))));
		}
		getContentPane().add(p1, "North");

		//East
		p1 = new JPanel();
		JPanel p2 = new JPanel(new GridLayout(3,1,5,5));
		p2.add(btAbrir = new JButton("Abrir"));
		p2.add(btSalvar = new JButton("Salvar"));
		p2.add(btFechar = new JButton("Fechar"));
		p1.add(p2);
		getContentPane().add("East", p1);

		//Center
		getContentPane().add(new JScrollPane(
				taEditor = new JTextArea()), "Center");
		btFechar.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent evento){
				btFecharClick();
			}


		});
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}

	private void btFecharClick() {
		System.exit(0);

	}

	public static void main(String args[]){
		@SuppressWarnings("unused")
		Exemplo3Gui janela = new Exemplo3Gui();
	}

}
